import Animal.Animal;
import Animal.Dog;
import Animal.Cat;
/*
*Description:
*User:laoHu
*Created with Intellij IDEA 2025
*Data:2025.05.00
*Time:00:00
*/
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.


    class B {
        public int Func() {
            System.out.print("B");
            return 0;
        }
    }
    class D extends B {
        @Override
        public int Func() {
            System.out.print("D");
            return 0;
        }
    }

class Person {

    private String name = "Person";

    int age = 0;

}

class Child extends Person {

    public String grade;

}

    public class Main {

        public static void main3(String[] args) {
            B a = new B();
            B b = new D();
            a.Func();
            b.Func();
        }

        public static void main2(String[] args) {

            Person p = new Child();
            //编译错误：private修饰的父类成员不可被子类访问
            // System.out.println(p.name);
        }

        public static void main(String[] args) {

            Animal animal = new Dog();

            if (animal instanceof Dog) {
                Dog dog = (Dog) animal;
                dog.bark();
            }

            //if(animal instanceof Cat){
            //ClassCastException:类转换异常
            Cat cat = (Cat) animal;
            cat.mem();
            //  }
        }
    }